package com.dayuanit.pokergame.rule;

import com.dayuanit.pokergame.GameUtil;
import com.dayuanit.pokergame.Person;
import com.dayuanit.pokergame.Poker;

/**
 * 对子的比较规则
 */
public class DoubleRuleEngine implements  RuleEngine {
    private static final int weight = 100;

    @Override
    public void juge(Person p1, Person p2) {
        Poker[] pokers1 = p1.getPokers();
        Poker[] pokers2 = p2.getPokers();

        //校验第一个玩家是不是对子 是的话 就加100分
        if (pokers1[0].getName().equals(pokers1[1].getName())) {
            GameUtil.sum(p1, weight);
        }

        //校验第二个玩家是不是对子 是的话 就加100分
        if (pokers2[0].getName().equals(pokers2[1].getName())) {
            GameUtil.sum(p2, weight);
        }
    }
}
